﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Xml.Linq;
using Microsoft.SharePoint;
using System.Text.RegularExpressions;

namespace LizardSoft.Common.FlexibleStructureDeployment
{
    public static partial class StructureHelper
    {
        private static void ProcessContentTypes(SPWeb web, ListProcessingInfo listProcessingInfo)
        {
            SPList list = GetSPListFromFolderUrl(web, listProcessingInfo.ListFolderUrl);
            if (!list.ContentTypesEnabled)
            {
                list.ContentTypesEnabled = true;
                list.Update();
            }

            AddNeededContentTypes(web, listProcessingInfo);
            DeleteNeededContentTypes(web, listProcessingInfo);
            PropagateChangesFromSiteFields(web, listProcessingInfo);
            // необходимо переоткрыть веб для обновления типов контента
            using (SPWeb newWeb = web.Site.OpenWeb(web.ID))
            {
                UpdateNeededContentTypes(newWeb, listProcessingInfo);
            }
        }
    }
}
